//
//  SqliteManager.h
//  HandleFarmer
//
//  Created by Cheney Lau on 7/30/14.
//  Copyright (c) 2014 Handou. All rights reserved.
//
/*
sql语句：
insert into statistic_ad(ad_id,click_times,show_times) values(11,10,10);
*/


#import <Foundation/Foundation.h>
#import "FMResultSet.h"
#import "FMDatabase.h"

@class FMResultSet;
@class FMDatabase;
@interface SqliteManager : NSObject

@property (nonatomic,strong) FMDatabase *db;

/**
 在bundle下面查找sqlite表结构文件
 */
+ (instancetype)sharedInstance;

/**
 select语句，返回一个结果集
 FMResultSet使用完一定要：close
 结果集使用方式：
 if(rs != nil)
 {
     while ([rs next]) {
         FMDBQuickCheck([[rs stringForColumn:@"a"] isEqualToString:@"Text1"]);
         FMDBQuickCheck([[rs stringForColumn:@"b"] isEqualToString:@"Text2"]);
         FMDBQuickCheck([rs intForColumn:@"c"] == 1);
         FMDBQuickCheck([rs doubleForColumn:@"d"] == 2.0);
     }
     [rs close];
 }
 */
- (FMResultSet *)executeQueryWithSql:(NSString *)sql;

/**
 执行返回是Bool类型
 
 sql形式：
 
 insert into testOneHundredTwelvePointTwo values (?, ?)
 
 param形式（?号个数代表参数个数，顺序就是？顺序）：
 
 [NSArray arrayWithObjects:@"one", [NSNumber numberWithInteger:2], nil]
 
 */
- (BOOL)executeUpdateWithSql:(NSString *)sql andParam:(NSArray *)param;

//// alex
//- (FMResultSet *)executeQueryWithSql:(NSString *)sql withArgumentsInArray:(NSArray*)argue;

@end
